package com.clk.portfoy.complib;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.clk.desktop.gui.components.basic.ClkLabel;

public class TextCellRenderer extends ClkLabel implements TableCellRenderer {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// ---------------------------------------------------------------------------------
	public TextCellRenderer() {
		this.setHorizontalTextPosition(RIGHT);
	}

	// ---------------------------------------------------------------------------------
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		this.setOpaque(true);
		if (isSelected) {
			this.setBackground(Color.GRAY);
			this.setForeground(Color.BLACK);
		} else {
			this.setBackground(Color.WHITE);
			this.setForeground(Color.BLACK);
		}
		if (value != null) {
			setText(value.toString());
		}
		return this;
	}
	// ---------------------------------------------------------------------------------
}